package com.bbz.generator.core.action.config;

import com.baomidou.mybatisplus.generator.config.rules.DbType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

/**
 * 默认的代码生成的配置
 *
 * @author binbin.a.zhang
 * @date 2018-05-22
 */
public class BbzGeneratorConfig extends AbstractGeneratorConfig {

	protected void globalConfig() {
		globalConfig.setOutputDir("C:\\workspace\\workopen\\bbz-0325\\bbz-crawler\\src\\main\\java");// 写自己项目的绝对路径,注意具体到java目录
		globalConfig.setFileOverride(true);
		globalConfig.setEnableCache(false);
		globalConfig.setBaseResultMap(true);
		globalConfig.setBaseColumnList(true);
		globalConfig.setOpen(false);
		globalConfig.setAuthor("binbin.a.zhang");
	}

	protected void dataSourceConfig() {
		/*dataSourceConfig.setDbType(DbType.SQL_SERVER);
		dataSourceConfig.setDriverName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
		dataSourceConfig.setUsername("sa");
		dataSourceConfig.setPassword("Zaq12wsx");
		dataSourceConfig.setUrl("jdbc:sqlserver://10.254.154.143:1433;DatabaseName=job-admin");*/
		dataSourceConfig.setDbType(DbType.MYSQL);
		dataSourceConfig.setDriverName("com.mysql.jdbc.Driver");
		dataSourceConfig.setUsername("root");
		dataSourceConfig.setPassword("1qaz!QAZ");
		dataSourceConfig.setUrl("jdbc:mysql://localhost:3306/bbz-0325");
	}

	protected void strategyConfig() {
		strategyConfig.setTablePrefix(new String[] { "sys_" });// 此处可以修改为您的表前缀
		strategyConfig.setNaming(NamingStrategy.underline_to_camel);
	}

	protected void packageConfig() {
		packageConfig.setParent(null);
		//指定生成实体Model包路径
		packageConfig.setEntity("com.bbz.crawler.core.commen.model");
		//指定生成Dao包路径
		packageConfig.setMapper("com.bbz.crawler.core.commen.mapper.dao");
		//指定生成Mapping包路径
		packageConfig.setXml("com.bbz.crawler.core.commen.mapper.mapping");
		//指定生成Service包路径
		packageConfig
		.setService("com.bbz.crawler.service");
		//指定生成ServiceImpl包路径
		packageConfig.setServiceImpl("com.bbz.crawler.service.impl");
		//指定生成ServiceImpl包路径
		packageConfig.setController("com.bbz.crawler.controller");
	}

	protected void templateConfig()
	{
		//指定自定义controller模板
		templateConfig.setController("/generatorTemplate/bbz/controller.java.vm");
	}

	@Override
	protected void config() {
		//全局配置
		globalConfig();
		//数据源配置
		dataSourceConfig();
		//策略配置
		strategyConfig();
		//包路径配置
		packageConfig();
		//模板配置
		templateConfig();

		
	}
}